<template>
    <view :class="{'integralitem item':true, 'cancelitem':objInfo.orderstate > 5} " :style="ind == 0 ? 'border-radius: 0  0 20rpx 20rpx;' : ''" v-if="objInfo.product">
        <view class="order-content" @click="toLink('order')">
            <view class="order-info flexbox">
                <view class="flexl order_detail flexbox">
                    <view class="pic loadingImg">
                        <image
                            :src="objInfo.product.litpic || defaultImg"
                            @error="objInfo.product.litpic = defaultImg"
                            mode="aspectFill"
                        />
                    </view>
                    <view class="detail">
                        <view class="h4">{{ objInfo.product && objInfo.product.title }}</view>
                        <view class="info">
                            <view class="p">使用积分{{ objInfo.point }}</view>
                        </view>
                    </view>
                </view>
                <view class="flexr order_count">
                    <view class="p_pirce">{{globalData.appConfig && globalData.appConfig.currency && globalData.appConfig.currency.symbol || '￥'}}{{ objInfo.product.mprice }}</view>
                    <view class="p_count">x{{ objInfo.count }}</view>
                </view>
            </view>
            <view class="order-pay flexbox" v-if="objInfo.orderstate < 6">
                <view>实付：</view>
                <view class="pay_price">
                    {{ globalData.appConfig && globalData.appConfig.currency && globalData.appConfig.currency.symbol || '￥'  }}
                    <view class="b">{{ objInfo.price.split('.')[0] }}<text v-if="objInfo.price.includes('.')">.{{ objInfo.price.split('.')[1] }}</text></view>
                </view>
            </view>
        </view>
        <view class="orderBtns" v-if="objInfo.orderstate < 5 &&  objInfo.orderstate != '1'">
            <template v-if="objInfo.orderstate == '0'">
                <view class="btn cancel" @click="toLink('cancel')">取消订单</view>
                <view class="btn pay" @click="toLink('pay')">去付款</view>
            </template>
            <template v-else-if="objInfo.orderstate <= 5 && objInfo.orderstate != '1'">
                <view class="btn detail" @click="toLink('wuliu')">查看物流</view>
            </template>
        </view>
        <view class="cancel_text" v-if="objInfo.orderstate > 5">取消</view>
    </view>
</template>
<script>
const app = getApp()
export default {
    props:{
        objInfo:{
            type:Object,
            default:{
                
            }
        },
        ind:{
            type:Number,
            default:0
        }
    },
    data(){
        return{
            globalData:app.globalData,
            imgVersion:app.globalData.imgVersion,
            imgpath:app.globalData.imgPath + '/member/order/',
            defaultImg:app.globalData.masterDomain + '/static/images/good_default.png',
        }
    },
    mounted(){
    },
    methods:{
            // 点击页面跳转 
            /***
             * @param {*} type 跳转类型  order => 详情   
             */
             toLink(type){
                const that = this;
                let url = ''
                switch(type){
                    case 'pay':
                        uni.$emit('payorder',{objInfo:this.objInfo,ind:this.ind})
                        break;
                    case 'cancel':
                        uni.$emit('cancelorder',{objInfo:this.objInfo,ind:this.ind})
                        break;
                    case 'order':
                        url = `${app.globalData.appConfig && app.globalData.appConfig.cfg_user_index }/orderdetail-integral-${that.objInfo.id}.html`
                        app.linkTo(url,false,false)
                        break;
                    case 'rebuy':
                        url = `${app.globalData.appConfig && app.globalData.appConfig.cfg_user_index }/orderdetail-integral-${that.objInfo.id}.html`
                        app.linkTo(url,false,false)
                        break;
                    case 'del':
                        url = `${app.globalData.appConfig && app.globalData.appConfig.cfg_user_index }/orderdetail-integral-${that.objInfo.id}.html`
                        uni.$emit('delorder',{objInfo:this.objInfo,ind:this.ind})
                        break;
                    case 'wuliu':
                        url = `${app.globalData.appConfig && app.globalData.appConfig.cfg_user_index }/orderdetail-integral-${that.objInfo.id}.html`
                        uni.$emit('showwuliu',{objInfo:this.objInfo,ind:this.ind})
                        break;
                }
            }
    }
}
</script>
<style scoped>
@import url(./orderlist_integral.css);
</style>